/**
 * @filename LoginService.java
 * @package com.tianjian.dass.service.system[DASS]
 * @description TODO
 * @author 胡正衛
 * @date 2012-6-4 上午12:58:44
 * @version v0.1
 */
package com.tianjian.oa.system.services;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tianjian.oa.system.mapper.SystemMapper;
import com.tianjian.oa.system.pojos.Message;

/**
 * @author 胡正衛
 */
@Service
public class SystemService {

	private static Message message = null;

	private static long lastget = System.currentTimeMillis() + 70000;

	Logger logger = Logger.getLogger(SystemService.class);

	@Autowired
	private SystemMapper systemMapper;

	public Message message() {
		if (System.currentTimeMillis() - lastget > 60000) {
			try {
				message = systemMapper.getSystemMessage();
				lastget = System.currentTimeMillis();
			} catch (Exception e) {
				logger.error(e.getMessage(), e);
			}
		}
		return message;
	}

}
